# # -*- coding:utf-8 -*-
# class Solution:
#     def LeftRotateString(self, s, n):
#         # write code here
#         return s[n:] + s[:n]
# -*- coding:utf-8 -*-
class Solution:
    def LeftRotateString(self, s, n):
        # write code here
        if not n or not s:
            return s
        s = list(s)[::-1]
        length = len(s)
        n %= length
        for i in range((length - n)//2):
            s[i], s[length - n - 1 - i] = s[length - n -1 -i], s[i]
        print(s)
        for i in range(length-n, length - n + n//2):
            print(i)
            print(length - i + n - 1)
            s[i], s[2 *length - i - n - 1] = s[2 * length - i - n -1], s[i]
        return ''.join(s)

test = Solution()
print(test.LeftRotateString('abcdefg', 2))